<?php
/**
 * Description of BonusService
 *
 * @author Magno
 */
class BonusService {


    private $bonusDAO;
    function __construct() {
        $this->bonusDAO = new BonusDAO();
    }


    public function salvar($bonus) {

        try {
            return $this->bonusDAO->salvar($bonus);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }

    }

    public function excluir($bonusID) {

        try {
            if(!isset ($bonusID) || $bonusID <= 0)
                throw new Exception("Codigo da Bonus Nao Econtrado!!!");

            $this->bonusDAO->excluir($bonusID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }

    }

    public function listar($pagina = 0,$descricao = "") {
        try {
            return $this->bonusDAO->listar($pagina, $descricao);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function listarPorOrdem($pagina = 0, $tamanho = 0, $ordem = "bonusID", $direcao = "DESC") {
        try {
            return $this->bonusDAO->listarPorOrdem($pagina, $tamanho, $ordem, $direcao);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function buscarPorID($bonusID) {
        try {
            if(!isset ($bonusID) || $bonusID <= 0)
                throw new Exception("Codigo da Bonus Nao Econtrado!!!");
            return $this->bonusDAO->buscarPorID($bonusID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function total($descricao = "") {
        try {
            return $this->bonusDAO->total($descricao);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }
}
?>
